if(Best == undefined){
	var Best = {};
}
Best.AddressSelectPopup = Ext.extend(Ext.Window, {
	width       : 534,
    height      : 245,
	rowdblclick : null,
	initComponent : function(){
        Best.AddressSelectPopup.superclass.initComponent.call(this);
        this.initGrid();
        this.show();
	},
	initGrid: function(){
		var cm = new Ext.grid.ColumnModel([{
	           header: '名字',
	           dataIndex: 'name',
	           width: 100
	        },{
	           header: '地区',
	           dataIndex: 'region',
	           width: 200
	        },{
	           header: '街道地址',
	           dataIndex: 'street',
	           width: 200
	        }
	    ]);
	
	    cm.defaultSortable = true;
	
		var url = 'addressBookList.html';
	    // create the Data Store
	    var store = new Ext.data.JsonStore({
	    	url: url,
	    	root: 'addressBooks',
	    	totalProperty: 'fullListSize',
	        fields: ['name', 'region', 'street', 'province', 'city', 'town', 'street', 'sender', 
	        		'telephoneAreaCode', 'telephoneNumber', 'telephoneExtention', 'mobilePhone',
	        		'postCode']
	    });
	    var pageSize = 8;
	    var pagingBar = new Ext.PagingToolbar({
	        pageSize: pageSize,
	        store: store,
	        displayInfo: true,
	        displayMsg: '显示 {0} - {1}条 总数 {2}条',
	        emptyMsg: "没有地址可以显示"
	    });
	    store.load({params:{start:0, limit:pageSize}});
		//var sm = new Ext.grid.RowSelectionModel({singleSelect:true});
		//sm.addListener('dblclick', this.ondblclick);
	    // create the editor grid
	    var grid = new Ext.grid.GridPanel({
	        store: store,
	        cm: cm,
	        width:520,
	        title:'',
	        frame:true,
	        height:233,
	        bbar:pagingBar,
	        loadMask:true
	    });
	    this.addSearch(grid);
	    this.add(grid);
	    grid.on('rowdblclick', this.rowdblclick);
	},
	addSearch: function(grid){
		var panel = new Ext.FormPanel(
			{
				baseCls:'',
				layout:'column',
				border : false,
				hideBorders:true,
				bodyBorder: false
			});
		var textfield = new Ext.form.TextField({name:'keyword', columnWidth: .25});
		panel.add(textfield);
		var button = new Ext.Toolbar.Button(
				{
					text:'搜索', 
					handler: function(){
						grid.store.load({params:{start:0, limit:8, keyword:textfield.getValue()}});
					}
					
				});
		var buttonPanel = new Ext.Panel({  baseCls:'',hideBorders:true, border: false,  bodyBorder: false, columnWidth: .25});
		buttonPanel.add(button);
		panel.add(buttonPanel);
		grid.add(panel);
	}
	
})